package com.saxon.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Properties_Servlet extends HttpServlet {
    @Override
    protected void doGet (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println (this.getServletContext ().getContextPath ());
        System.out.println ("start***************************");
        InputStream is = this.getServletContext ().getResourceAsStream ("/WEB-INF/classes/lover.properties");
        Properties prop = new Properties ();
        prop.load (is);
        String username = prop.getProperty ("username");
        String pwd = prop.getProperty ("pwd");
        resp.getWriter ().print (username + ":" + pwd);
        is.close ();
    }

    @Override
    protected void doPost (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet (req, resp);
    }

}
